package cn.itutu.demo.junit;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Created by itutu on 2018/4/16.
 * Description:
 */
public class Junit4Demo_Exception {
    Calculator calculator = new Calculator();
    @Test(expected=NullPointerException.class)
    public void testException1() throws Exception {
        System.out.println("throw new NullPointerException");
        assertEquals(9, calculator.add(3,6));
        throw new NullPointerException("空指针异常");
    }

    @Test(expected=NullPointerException.class)
    public void testException2() throws Exception {
        System.out.println("throw new Exception");
        assertEquals(9, calculator.add(3,6));
        throw new Exception("空指针异常");
    }
}
